<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="layout/default">
<head lang="en">
    <title>Your profile</title>
</head>
<body>
<div class="row" layout:fragment="content">
    <h2 class="indigo-text center">Personal info</h2>
    <form th:action="@{/profile}" th:object="${profileForm}" method="post" class="'col m8 s12 offset-m2">
        <ul th:if="${#fields.hasErrors('*')}" class="errorlist">
            <li th:each="err : ${#fields.errors('*')}" th:text="${err}">Input is incorrect</li>
        </ul>
        <div class="row">
            <div class="input-field col s6">
                <input th:field="${profileForm.twitterHandle}" id="twitterHandle" type="text" required="required" th:errorclass="invalid"/>
                <label for="twitterHandle">Last Name</label>
                <div th:errors="*{twitterHandle}" class="red-text">Error</div>
            </div>
            <div class="input-field col s6">
                <input th:field="${profileForm.email}" id="email" type="email" required="required" th:errorclass="invalid"/>
                <label for="email">Email</label>
                <div th:errors="*{email}" class="red-text">Error</div>
            </div>
            <div class="input-field col s6">
                <input th:field="${profileForm.birthDate}" id="birthDate" type="text" required="required" th:errorclass="invalid" th:placeholder="${dateFormat}"/>
                <label for="birthDate">Birth</label>
                <div th:errors="*{birthDate}" class="red-text">Error</div>
            </div>

            <fieldset class="row">
                <legend th:text="#{tastes.legend}">What do you like?</legend>
                <button class="btn teal" type="submit" name="addTaste" th:text="#{add.taste}">
                    Add taste
                    <i class="mdi-content-add left"></i>
                </button>

                <div th:errors="*{tastes}" class="red-text">Error</div>

                <div class="row" th:each="row, rowStat: *{tastes}">
                    <div class="col s6">
                        <input type="text" required="required" th:field="*{tastes[__${rowStat.index}__]}" th:placeholder="#{taste.placeholder}"/>
                    </div>
                    <div class="col s6">
                        <button class="btn red" type="submit" name="removeTaste" th:value="${rowStat.index}" th:text="#{remove}">Remove
                        <i class="mdi-action-delete right waves-effect"></i>
                        </button>
                    </div>
                </div>
            </fieldset>

            <div class="row s12">
                <button class="btn waves-effect waves-light" type="submit" name="save">Submit
                    <i class="mdi-content-send right"></i>
                </button>
            </div>
        </div>
    </form>
</div>
</body>
</html>
